﻿using System;
using System.Collections.Generic;

using System.Text;

namespace TA.Turbo.Controls
{
	/// <summary>
	/// Outputs ImageButton controls.
	/// </summary>
	public class ImageButtonColumn : BaseCommandColumn
	{
		/// <summary>
		/// Virtual path to the image displayed in the button.
		/// </summary>
		public string Src { get; set; }
		/// <summary>
		/// Creates the view mode ImageButton.
		/// </summary>
		/// <param name="container"></param>
		public override void CreateViewItem(System.Web.UI.Control container, Grid owner)
		{
			if (string.IsNullOrEmpty(ViewControl.Id))
				ViewControl.Id = "btn" + Command;
			ImageButton b = new ImageButton
			{
				ID = ViewControl.Id,
				CssClass = ViewControl.CssClass,
				Src = Src,
			};
			b.Click.Client = this.ClickClientJS;
			b.Attributes["style"] = ViewControl.Style;
			container.Controls.Add(b);
		}
		/// <summary>
		/// Creates the edit mode ImageButton.
		/// </summary>
		/// <param name="container"></param>
		public override void CreateEditItem(System.Web.UI.Control container, Grid owner)
		{
			if (string.IsNullOrEmpty(ViewControl.Id))
				ViewControl.Id = "btn" + Command;
			ImageButton b = new ImageButton
			{
				ID = ViewControl.Id,
				CssClass = ViewControl.CssClass,
				Src = Src,
			};
			b.Click.Client = this.ClickClientJS;
			b.Attributes["style"] = ViewControl.Style;
			container.Controls.Add(b);
		}
	}
}
